package org.pine.common.components;

import org.pine.common.beans.SysLogBody;

/**
 * 系统日志上下文
 *
 * @author pine
 * @version v1.0
 * @since 2025-04-28 22:38
 */
public class SysLogContext {
    /**
     * 日志上下文-threadLocal
     */
    private static final ThreadLocal<SysLogBody> SYS_LOG_BODY_THREAD_LOCAL = new InheritableThreadLocal<>();

    /**
     * 添加日志上下文
     *
     * @param log 日志上下文
     */
    public static void add(SysLogBody log) {
        SYS_LOG_BODY_THREAD_LOCAL.set(log);
    }


    /**
     * 获取日志上下文
     *
     * @return 日志上下文列表
     */
    public static SysLogBody get() {
        return SYS_LOG_BODY_THREAD_LOCAL.get();
    }


    /**
     * 清空日志上下文
     */
    public static void clear() {
        SYS_LOG_BODY_THREAD_LOCAL.remove();
    }
}
